<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">











<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>NPanday - Project Dependencies</title>
    <style type="text/css" media="all">
      @import url("../../css/maven-base.css");
      @import url("../../css/maven-theme.css");
      @import url("../../css/site.css");
    </style>
    <link rel="stylesheet" href="../../css/print.css" type="text/css" media="print" />
          </head>
  <body class="composite">
    <div id="banner">
                  <a href="" id="bannerLeft">
    
                                            <img src="../.././images/NPanday.png" alt="" />
    
            </a>
                        <a href="http://www.codeplex.com/" id="bannerRight">
    
                                            <img src="../.././images/logo-home.png" alt="" />
    
            </a>
            <div class="clear">
        <hr/>
      </div>
    </div>
    <div id="breadcrumbs">
          
  

  
    
            
  
    
            <div class="xleft">
          
                <a href="http://npanday.codeplex.com/" class="externalLink">NPanday Home</a>
                &gt;
      
                <a href="../../">NPanday 1.2</a>
                  </div>
            <div class="xright">      
  

  
    
            
  
    
             Last Published: 22 Jun 2010
              &nbsp;| Version: 1.2
            </div>
      <div class="clear">
        <hr/>
      </div>
    </div>
    <div id="leftColumn">
      <div id="navcolumn">
           
  

  
    
            
  
    
                   <h5>General Info</h5>
            <ul>
              
    <li class="none">
                    <a href="../../index.html">NPanday Overview</a>
          </li>
              
    <li class="none">
                    <a href="../../release-notes.html">NPanday Release Notes</a>
          </li>
              
    <li class="none">
                    <a href="../../faqs.html">NPanday FAQs</a>
          </li>
              
    <li class="none">
                    <a href="../../faqs.html">NPanday Features</a>
          </li>
              
    <li class="none">
                    <a href="../../npanday.pdf">Documentation PDF</a>
          </li>
          </ul>
              <h5>User's Guide</h5>
            <ul>
              
    <li class="none">
                    <a href="../.././guide/index.html">Introduction</a>
          </li>
              
    <li class="none">
                    <a href="../.././guide/installation/index.html">Installation</a>
          </li>
              
    <li class="none">
                    <a href="../.././guide/vs/index.html">Visual Studio Add-in</a>
          </li>
              
    <li class="none">
                    <a href="../.././guide/maven/index.html">Maven Command Line</a>
          </li>
              
    <li class="none">
                    <a href="../.././guide/devinfra/index.html">Maven Development Infrastructure</a>
          </li>
              
    <li class="none">
                    <a href="../../plugins/index.html">NPanday Plugins</a>
          </li>
          </ul>
              <h5>Contributing</h5>
            <ul>
              
    <li class="none">
                    <a href="../.././developers/index.html">Developer's Guide</a>
          </li>
              
    <li class="none">
                    <a href="../.././issue-tracking.html">Issue Tracking</a>
          </li>
              
    <li class="none">
                    <a href="../.././mail-lists.html">Mailing Lists</a>
          </li>
          </ul>
              <h5>Project Documentation</h5>
            <ul>
              
                
              
      
            
      
            
      
            
      
            
      
            
      
            
      
              
        <li class="collapsed">
                    <a href="../../project-info.html">Project Information</a>
                </li>
          </ul>
              <h5>Resources</h5>
            <ul>
              
    <li class="none">
                    <a href="http://maven.apache.org/" class="externalLink">Apache Maven</a>
          </li>
              
    <li class="none">
                    <a href="http://npanday.codeplex.com/" class="externalLink">NPanday on CodePlex</a>
          </li>
          </ul>
                                           <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
            <img alt="Built by Maven" src="../../images/logos/maven-feather.png"></img>
          </a>
                       
  

  
    
            
  
    
        </div>
    </div>
    <div id="bodyColumn">
      <div id="contentBox">
        <div class="section"><h2>Project Dependencies</h2>
<p>This feature allows the Visual Studio user to browse managed repositories and add and delete Maven dependencies to and from the repositories from within the Visual Studio IDE.</p>
<p>A remote repository must be configured before attempting to use this feature. Please see the <a href="./configureRepository.html"> Remote Repository</a> section for instructions.</p>
<p><b>Note</b>: Adding dependencies should be done using Visual Studio while manually adding is not recommended. At this time, the Visual Studio add-in will not detect changes to the Maven dependencies and add them to your Visual Studio project. If you manually add a dependency and re-import the project in Visual Studio, the recently added dependencies are deleted from the <tt>pom.xml</tt> file.</p>
<div class="section"><h3>Adding Maven Artifacts</h3>
<p>Adding a Maven artifact allows you to refer to a DLL or other dependency that may not yet be installed on the local machine. This is done by consulting a Maven <i>remote repository</i> for available dependencies, and adding a reference to the Maven <tt>pom.xml</tt>.</p>
<p>When adding an artifact dependency into a web site project, there will be no changes in the <tt>pom.xml</tt>. This is because the artifacts are put directly into the project's <tt>bin\</tt> directory (one is created when this is missing), thus, <tt> &lt;dependencies&gt; </tt> in the <tt>pom.xml</tt> is not needed.</p>
<p>To add an artifact:</p>
<ol type="1"><li>Right-click on a project and select Add Maven Artifact... from the menu.</li>
<li>In the Add Maven Artifact pop-up window there are tabs for each repository you have configured. Click the tab for the repository in which the desired artifact is located.</li>
<li>Scroll to select the desired artifact (must be a <tt>DLL</tt> file, not a <tt>JAR</tt> nor an <tt>OCX</tt> file):</li>
<li>Click Add to add the selected artifact and exit the form. Or, double click on the artifact to be added. Repeat this step to add multiple artifacts. Then, click Close to exit the form.</li>
</ol>
<img src="../../images/vs/add_artifact.jpg" alt="Add Maven Artifact screen" /><p>The artifacts will be added as a reference to the project and added as a dependency in the POM file. It is also downloaded to the <tt>C:\Documents and Settings\[user_home]\.m2\uac</tt> directory.</p>
<div class="section"><h4>COM References</h4>
<p>When attempting to add an <tt>.ocx</tt> file into the repository, a warning message similar to the following will be displayed:</p>
<img src="../../images/vs/com_reference.jpg" alt="COM reference error message" /><p>See below for adding COM references directly.</p>
</div>
<div class="section"><h4>.NET References</h4>
<p>As of version 1.2 when adding .NET References NPanday will no longer add system scope and system path properties on the .NET dependency.</p>
</div>
</div>
<div class="section"><h3>Adding References</h3>
<p>You can also add traditional references to the project and have NPanday translate them into Maven dependencies.</p>
<p>To add references to the project:</p>
<ol type="1"><li>Right click on the project that you want to add a reference to.</li>
<li>Select Add Reference... from the menu list.</li>
<li>Select the tab to which the reference belongs (<b>.NET</b>, <b>COM</b>, <b>Projects</b>). Or, Browse to look for the specific artifact to be reference and Recent for artifacts recently accessed.</li>
<li>Select the references to be added from the list as shown in the figure above. Scroll to select the desired object reference.</li>
<li>Click OK.</li>
</ol>
<img src="../../images/vs/references_list.jpg" alt="Sample display of list of references" /><p>NPanday will take care of adding the reference to the Maven POM automatically. In most cases this will also be made available on any other system building from the Maven project. In the case of an inter-project dependency, it will rely on the project being built on the target machine before the project that has the dependency on it - but all that is needed here is to build the whole solution as Maven will then take care of the correct ordering.</p>
<p>However, some references are non-portable when they are added.</p>
<div class="section"><h4>Intra Solution References</h4>
<p>When Adding Intra Solution references use the Visual Studio &quot;Add Reference&quot; and not the &quot;Add Maven Artifact&quot; command. This sets the csproj/vbproj file &amp; the pom.xml correctly simultaenously, and allows VS to build the project without needing to resolve the reference.</p>
</div>
<div class="section"><h4>Non-portable References</h4>
<p>When adding a COM reference, the actual reference (DLL) is copied to <tt>C:\WINDOWS\assembly\GAC_MSIL</tt>. Wherein, the path to the reference found in this directory is used as the reference's <tt> &lt;systemPath&gt; </tt> in the <tt>pom.xml</tt>. References such as this rely on the given DLL being available at the same location on each machine.</p>
<p>When adding an artifact reference that is not installed in the system, NPanday will prompt a warning message then adds the reference in the <tt>pom.xml</tt> as a system scope dependency.</p>
<img src="../../images/vs/dependency_error.jpg" alt="Reference not installed in the system" /><p>However, the above warning message is not displayed for web site projects even if the artifact reference to be added is not installed in the system. This is because the artifact references for web projects are directly added in the project's <tt>bin\</tt> directory (one is created when this is missing), thus, no need to add it in the <tt>pom.xml</tt>.</p>
<p>The following POM snippet shows a system dependency:</p>
<div class="source"><pre>  &lt;dependency&gt;
    &lt;groupId&gt;artifact_group_id&lt;/groupId&gt;
    &lt;artifactId&gt;my.lib&lt;/artifactId&gt;
    &lt;version&gt;2.2&lt;/version&gt;
    &lt;type&gt;library&lt;/type&gt;
    &lt;scope&gt;system&lt;/scope&gt;
    &lt;systemPath&gt;C:\path\to\your\library.dll&lt;/systemPath&gt;
  &lt;/dependency&gt;</pre>
</div>
</div>
</div>
<div class="section"><h3>Removing Artifacts and References</h3>
<p>The Remove Artifact feature removes the artifact as a reference to the project and as a dependency in the POM file.</p>
<p>To remove an artifact, you can select the artifacts to remove and click the Delete key. This works for both Visual Basic and C# projects.</p>
<p>Alternatively, to remove Visual Basic project artifact:</p>
<ol type="1"><li>Right-click on a project and select Properties from the menu.</li>
<li>Click on the References tab, and select the desired artifact.</li>
<li>Click Remove.</li>
</ol>
<p>Alternatively, to remove C# project artifact:</p>
<ol type="1"><li>Inside the project, browse through the References folder.</li>
<li>Right click on the desired artifact and select Remove.</li>
</ol>
</div>
<div class="section"><h3>Summary</h3>
<p>This has covered all options for adding one of Maven's most powerful features - dependency resolution - to your .NET projects by using NPanday.</p>
<p>The next section continues with <a href="./webReferences.html"> web references</a>. You can also go back to the <a href="./index.html"> index</a>.</p>
<p>In the next section we revisit <a href="./importing.html"> importing a project into Maven</a>. Other topics are available on the <a href="./index.html"> index</a>.</p>
</div>
</div>

      </div>
    </div>
    <div class="clear">
      <hr/>
    </div>
    <div id="footer">
      <div class="xright">&#169;  
          2010
    
          NPanday
          
  

  
    
            
  
    
  </div>
      <div class="clear">
        <hr/>
      </div>
    </div>
  </body>
</html>
